package operation;

import student.Student;
import student.StudentList;

import java.util.Scanner;

public class DelOperation implements IOperation{
    @Override
    public void work(StudentList list) {
        System.out.println("删除学生信息");
        int sz = list.size();
        if(sz == 0){
            throw new IsEmptyException("该学生表为空，不能进行删除");
        }
        System.out.println("请输入你要删除的学生的学号:->");
        Scanner sc = new Scanner(System.in);
        String stuId = sc.next();
        for(int i = 0; i < sz; i++){
            Student stu = list.get(i);
            if(stu.getStudentId().equals(stuId)){
                list.remove(i);
                System.out.println("删除成功");
                return;
            }
        }
        System.out.println("该学生表中，为查找到该学生");
    }
}
